//在子窗口通过调用客户端程序来实现tabLayout中新增tab
function addCenterLayoutTab(tarid, tabTitle, targetUrl, refreshable, callback) {
	var needFresh = false;
	if (refreshable != null && refreshable != '' && refreshable == true) {
		needFresh = true;
	}
	// 得到主窗口中的tablayout
	var mainPanel;
	if (typeof (window.top.centerPanelJsvar) != 'undefined') {
		mainPanel = window.top.centerPanelJsvar;
	}
	// 在tablayout中增加tab页
	var item = mainPanel.getItem(tarid);
	if (item) {
		item.setTitle(tabTitle);
		var tabFrame = item.getEl().dom.childNodes[0].childNodes[0].childNodes[0];
		Ext.get(tabFrame).dom.src = targetUrl;
	} else {
		mainPanel
				.add( {
					id : tarid,
					title : tabTitle,
					html : "<iframe id='"
							+ tarid
							+ "_frm' name='"
							+ tarid
							+ "_frm' src='"
							+ targetUrl
							+ "' frameborder='0' width='100%' height='100%' scrolling='auto' marginwidth='0' marginheight='2'></iframe>",
					closable : true,
					listeners : {
						activate : function(tab) {
							if (needFresh) {
								var tabFrame = tab.getEl().dom.childNodes[0].childNodes[0].childNodes[0];
								var temploc = Ext.get(tabFrame).dom;
								// 如果有回调方法，执行回调方法，如果没有，直接刷新页面
								if (callback) {
									eval("if(typeof (temploc.contentWindow."
											+ callback
											+ ") != 'undefined'){temploc.contentWindow."
											+ callback + "();}");
								} else if (temploc.src != '') {
									temploc.src = temploc.src;
								}
							}
						}
					}
				});
	}
	// 激活该页
	mainPanel.setActiveTab(tarid);
}

function closeCenterLayoutTab(tarid) {
	if (typeof (window.top.centerPanelJsvar) != 'undefined') {
		window.top.centerPanelJsvar.remove(tarid);
	}
}

/*
 * 关闭当前活动的窗口
 */
function closeCenterLayoutActiveTab() {
	if (typeof (window.top.centerPanelJsvar) != 'undefined') {
		var mainPanel = window.top.centerPanelJsvar;
		mainPanel.remove(mainPanel.getActiveTab());
	}
}
// 出一个确认框
function showConfirm(msg) {
	return confirm(msg);
}

function voidMethod() {
}

function showMain() {
	var ele = personPageJsvar_frame;
	// alert(ele.location);
	// ele.dom.reload();
	ele.location.href = ele.location.href;
	centerPanelJsvar.activate(personPageJsvar.getItemId());
}
// 刷新本页
function reloadPage() {
	var url = window.location.href;
	window.location.href = url;
}
// 刷新附件
function refreshAttachment(frameId){
	var frame=document.getElementsByName(frameId)[0];
	frame.contentWindow.reloadAttach();
}
// 关闭附件窗口
function closeAttachWindow(fileUpload, attachFrame) {
	fileUpload.hide();
	attachFrame.reloadAttach();
}
function dateBefore(d1, d2) {
	var pStart = Date.parse(d1);
	var pEnd = Date.parse(d2);
	if (pStart - pEnd < 0)
		return true;
	return false;
}
function dateAfter(d1, d2) {
	var pStart = Date.parse(d1);
	var pEnd = Date.parse(d2);
	if (pStart - pEnd > 0)
		return true;
	return false;
}
function dateEquals(d1, d2) {
	var pStart = Date.parse(d1);
	var pEnd = Date.parse(d2);
	if (pStart - pEnd == 0)
		return true;
	return false;
}
function getString(d) {
	if (d == null)
		return '';
	var cYear = d.getFullYear();
	var cMonth = d.getMonth() + 1;
	var date = d.getDate();
	return cYear + '-' + cMonth + '-' + date;
}
function getDate(str) {
	if (str == null)
		return;
	var temp = str.split('-');
	var d = new Date();
	d.setFullYear(temp[0]);
	d.setMonth(temp[1] - 1);
	d.setDate(temp[2]);
	return d;
}
// 获得时间字符串 形如[2010-10-10 00:00:00]
function getDateString(d) {
	if (d == null)
		return '';
	var cYear = d.getFullYear();
	var cMonth = d.getMonth() + 1;
	var date = d.getDate();
	var hour=d.getHours();
	var min=d.getMinutes();
	var sec=d.getSeconds();
	return cYear + '-' + cMonth + '-' + date +' '+hour+':'+min+':'+sec;
}
function mailFormatter(v, m , r, rIndex){
	if(v!=null){
		var script='mailto:'+v;
		return '<a href="'+script+'">'+v+'</a>';
	}else{
		return "";
	}
}
function websiteFormatter(v, m , r, rIndex){
	if(v!=null){
		return '<a href="'+v+'" target="_blank">'+v+'</a>';
	}else{
		return "";
	}
}
function addCenterLayoutTabForRepositoryMenu(tarid, tabTitle, targetUrl,currentPath, refreshable, callback) {
			var needFresh = false;
			if (refreshable != null && refreshable != '' && refreshable == true) {
				needFresh = true;
			}
			// 得到主窗口中的tablayout
			var mainPanel;
			if (typeof (window.top.centerPanelJsvar) != 'undefined') {
				mainPanel = window.top.centerPanelJsvar;
			}
			// 在tablayout中增加tab页
			var item = mainPanel.getItem(tarid);
			if (item) {
				item.setTitle(tabTitle);
				var tabFrame = item.getEl().dom.childNodes[0].childNodes[0].childNodes[0];
				Ext.get(tabFrame).dom.contentWindow.changePanelTitleForAddCenterTab(currentPath);
			} else {
				mainPanel
						.add( {
							id : tarid,
							title : tabTitle,
							html : "<iframe id='"
									+ tarid
									+ "_frm' name='"
									+ tarid
									+ "_frm' src='"
									+ targetUrl
									+ "' frameborder='0' width='100%' height='100%' scrolling='auto' marginwidth='0' marginheight='2'></iframe>",
							closable : true,
							listeners : {
								activate : function(tab) {
									if (needFresh) {
										var tabFrame = tab.getEl().dom.childNodes[0].childNodes[0].childNodes[0];
										var temploc = Ext.get(tabFrame).dom;
										// 如果有回调方法，执行回调方法，如果没有，直接刷新页面
										if (callback) {
											eval("if(typeof (temploc.contentWindow."
													+ callback
													+ ") != 'undefined'){temploc.contentWindow."
													+ callback + "();}");
										} else if (temploc.src != '') {
											temploc.src = temploc.src;
										}
									}
								}
							}
						});
			}
			// 激活该页
			mainPanel.setActiveTab(tarid);
		}